#ifdef a
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//flowers and plants
typedef struct Name {
    char _name[30];
}Name;
int My_Cmp(const void* p1, const void* p2) {
    return strcmp(((Name*)p1)->_name, ((Name*)p2)->_name);
}
//排序
void My_Qsort(Name name[], int sz) {
    qsort(name, sz, sizeof(Name), My_Cmp);
    printf("\n");
    printf("---排序后---\n");
    for (int i = 0; i < sz; i++)
        printf("%s\n", name[i]._name);
}
int My_Find(Name name[], int sz,char find[]) {
    for (int i = 0; i < sz; i++) {
        if (!strcmp(name[i]._name, find))
            return 1;
    }
    return 0;
}
int main() {
    FILE* pf = fopen("flowers and plants.txt", "rb");
    if (!pf) {
        perror("open error");
        return -1;
    }
    Name name[30] = { 0 };
    int sz = 0;
    //文件读取并输出
    while (fgets(name[sz]._name, 10, pf) != NULL) {
        printf("%s", name[sz++]._name);
    };
    //对字符串结尾读取到的'\r\n'的处理
    for (int i = 0; i < sz; i++) {
        char* tmp = name[i]._name;
        while (*tmp) {
            if (*tmp == '\r')
                *tmp = '\0';
            tmp++;
        }
    }
    //排序并比较
    My_Qsort(name, sz);
    char find[20] = { 0 };
    printf("\n输入要查找的英文名称>>");
    scanf("%s", find);
    int ret = My_Find(name, sz, find);
    if (ret)
        printf("存在\n");
    else
        printf("不存在\n");
    fclose(pf);
    pf = NULL;
}
#endif